<template>
    <div class="box">
        <div style="padding:0 10px;">
            <van-field v-model="name" placeholder="请输入商品名称" />
            <van-button type="info" style="width:100%;font-size: 16px;" @click="addgoods">添加商品</van-button>
        </div>
    </div>
</template>
<script>
import { Toast, Dialog } from 'vant';
export default {
    data () {
        return {
            name:''
        };
    },
    methods:{
        async addgoods(){
            if(this.name.trim().length == 0) return Toast.fail('请输入商品名称');
            const {data:res} = await this.$axios.post("/api/addproduct",{name:this.name});
            if(res.status !== 0) return Toast.fail('添加失败');
            Toast.success('添加成功');
            this.$router.push('/search')
        }
    },
    created (){
    
    },
    mounted (){
    
    },
}
</script>
<style scoped lang="less">
    .van-field{
        
        border-bottom:1px solid #ebedf0;
        margin-bottom:30px;
    }
</style>